#ifndef EJCONFIG_H
#define EJCONFIG_H
#include <QXmlStreamReader>
#include <QVector>
#include <QList>
#include <QMap>
struct EJAttr
{
    QString  name = "";
    QString  value = "";
    EJAttr(){}
    EJAttr(const QString &attName, const QString &attValue):name(attName), value(attValue){}
};

struct EJModule
{
    QString                key = "";
    QString                value = "";
    QMap<QString, QString> attr;
    QList<EJModule *>      child;
};


class EJConfig
{
public:
    ~EJConfig();

    bool          open(const QString &name);

    QMap<QString, QString>&getAttr(const QStringList &lable);
    QStringList            getAttr(const QStringList &lable, const QString &subLable, const QString &attrName);

    QStringList            getValue(const QStringList &lable, const QString &subLable);

    bool                   addAttr(const QStringList &lable, const QString &attrName, const QString &attrValue);
    bool                   setValue(const QStringList &lable, const QStringList &subLable, const QStringList &subValue);

protected:
    void         parse();
    void         write();

protected:
    QXmlStreamReader m_xml;
    QString          m_file;
    EJModule         m_moudle;
};

#endif // EJCONFIG_H
